package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.TJoinApply;
import com.ruoyi.business.service.ITJoinApplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 加盟申请Controller
 * 
 * @author laougo
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/business/joinApply")
public class TJoinApplyController extends BaseController
{
    @Autowired
    private ITJoinApplyService tJoinApplyService;

    /**
     * 查询加盟申请列表
     */
    @PreAuthorize("@ss.hasPermi('business:joinApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(TJoinApply tJoinApply)
    {
        startPage();
        List<TJoinApply> list = tJoinApplyService.selectTJoinApplyList(tJoinApply);
        return getDataTable(list);
    }

    /**
     * 导出加盟申请列表
     */
    @PreAuthorize("@ss.hasPermi('business:joinApply:export')")
    @Log(title = "加盟申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TJoinApply tJoinApply)
    {
        List<TJoinApply> list = tJoinApplyService.selectTJoinApplyList(tJoinApply);
        ExcelUtil<TJoinApply> util = new ExcelUtil<TJoinApply>(TJoinApply.class);
        util.exportExcel(response, list, "加盟申请数据");
    }

    /**
     * 获取加盟申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:joinApply:query')")
    @GetMapping(value = "/{applyId}")
    public AjaxResult getInfo(@PathVariable("applyId") Long applyId)
    {
        return success(tJoinApplyService.selectTJoinApplyByApplyId(applyId));
    }

    /**
     * 新增加盟申请
     */
    @PreAuthorize("@ss.hasPermi('business:joinApply:add')")
    @Log(title = "加盟申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TJoinApply tJoinApply)
    {
        return toAjax(tJoinApplyService.insertTJoinApply(tJoinApply));
    }

    /**
     * 修改加盟申请
     */
    @PreAuthorize("@ss.hasPermi('business:joinApply:edit')")
    @Log(title = "加盟申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TJoinApply tJoinApply)
    {
        return toAjax(tJoinApplyService.updateTJoinApply(tJoinApply));
    }

    /**
     * 删除加盟申请
     */
    @PreAuthorize("@ss.hasPermi('business:joinApply:remove')")
    @Log(title = "加盟申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applyIds}")
    public AjaxResult remove(@PathVariable Long[] applyIds)
    {
        return toAjax(tJoinApplyService.deleteTJoinApplyByApplyIds(applyIds));
    }
}
